/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.ipti.br.tag.entity;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import org.ipti.br.tag.util.EncryptionUtil;

/**
 *
 * @author israel
 */
@Entity
public class Grants extends AbstractEntity{
    
    @ManyToOne
    @JoinColumn(name = "functionality_id", nullable = false)
    private Functionality functionality;

    @Column(name="unity_id")
    private Long unityID;
    
    @Column(name="personage_id")
    private Long personageID;
    
    @Column(name="actor_id")
    private Long actorID;
    
    @Column(name="organization_apply_id")
    private Long organizationApplyID;
    
    @Column(name="unity_apply_id")
    private Long unityApplyID;
    
    @Column(name="personage_apply_id")
    private Long personageApplyID;
    
    @Column(name="actor_apply_id")
    private Long actorApplyID;
    
    private Boolean selec;
    private Boolean inser;
    private Boolean updat;
    private Boolean delet;
    
    public Grants() {
    }

    @Override
    public void generateHash(){
        if(getId() == null){
            String hash = ""
                    + ((this.getFunctionality() != null) ? this.getFunctionality().getId() : null)
                    + this.getUnityID()
                    + this.getPersonageID()
                    + this.getActorID()
                    + this.getOrganizationApplyID()
                    + this.getUnityApplyID()
                    + this.getPersonageApplyID()
                    + this.getActorApplyID();
            this.setId(Long.valueOf(EncryptionUtil.encrypt(hash).hashCode()));
        }
    }

    public Grants(Functionality functionality, Long unityID, Long personageID, Long actorID, Long organizationApplyID, Long unityApplyID, Long personageApplyID, Long actorApplyID, Boolean selec, Boolean inser, Boolean updat, Boolean delet) {
        this.functionality = functionality;
        this.unityID = unityID;
        this.personageID = personageID;
        this.actorID = actorID;
        this.organizationApplyID = organizationApplyID;
        this.unityApplyID = unityApplyID;
        this.personageApplyID = personageApplyID;
        this.actorApplyID = actorApplyID;
        this.selec = selec;
        this.inser = inser;
        this.updat = updat;
        this.delet = delet;
    }

    public Long getActorApplyID() {
        return actorApplyID;
    }

    public void setActorApplyID(Long actorApplyID) {
        this.actorApplyID = actorApplyID;
    }

    public Long getActorID() {
        return actorID;
    }

    public void setActorID(Long actorID) {
        this.actorID = actorID;
    }

    public Boolean getDelet() {
        return delet;
    }

    public void setDelet(Boolean delet) {
        this.delet = delet;
    }

    public Functionality getFunctionality() {
        return functionality;
    }

    public void setFunctionality(Functionality functionality) {
        this.functionality = functionality;
    }

    public Boolean getInser() {
        return inser;
    }

    public void setInser(Boolean inser) {
        this.inser = inser;
    }

    public Long getOrganizationApplyID() {
        return organizationApplyID;
    }

    public void setOrganizationApplyID(Long organizationApplyID) {
        this.organizationApplyID = organizationApplyID;
    }

    public Long getPersonageApplyID() {
        return personageApplyID;
    }

    public void setPersonageApplyID(Long personageApplyID) {
        this.personageApplyID = personageApplyID;
    }

    public Long getPersonageID() {
        return personageID;
    }

    public void setPersonageID(Long personageID) {
        this.personageID = personageID;
    }

    public Boolean getSelec() {
        return selec;
    }

    public void setSelec(Boolean selec) {
        this.selec = selec;
    }

    public Long getUnityApplyID() {
        return unityApplyID;
    }

    public void setUnityApplyID(Long unityApplyID) {
        this.unityApplyID = unityApplyID;
    }

    public Long getUnityID() {
        return unityID;
    }

    public void setUnityID(Long unityID) {
        this.unityID = unityID;
    }

    public Boolean getUpdat() {
        return updat;
    }

    public void setUpdat(Boolean updat) {
        this.updat = updat;
    }
}
